package edu.fim.data.dao.factory;

import javax.sql.DataSource;

import edu.fim.data.dao.ConsumerDAO;
import edu.fim.data.dao.FoodDAO;

/**
 * The DaoFactory implements the Singleton Design Pattern, and is
 * responsible for instantiating all types of Data Access Objects.
 * It also has a DataSource, which is given to all DAOs during
 * their creation.
 * 
 * @author Itikawa
 */
public class DAOFactory {
	
	private static final DAOFactory INSTANCE = new DAOFactory();
	
	private DataSource dataSource;

	private DAOFactory() {
	}
	
	public static DAOFactory getInstance() {
		return INSTANCE;
	}
	
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	
	public ConsumerDAO createConsumerDao() {
		return new ConsumerDAO(dataSource);
	}
	
	public FoodDAO createFoodDao() {
		return new FoodDAO(dataSource);
	}
}